#ifndef _APP_EPD_H_
#define _APP_EPD_H_

#include "epd.h"
#include "epd_port.h"
#include "esp_err.h"
#include <stdint.h>
#include "driver/spi_master.h"
#include "sdkconfig.h"

#define EPD_WIDTH CONFIG_EPD_WIDTH
#define EPD_HEIGHT CONFIG_EPD_HEIGHT
#define EPD_DIS_BUF_SIZE (EPD_WIDTH * CONFIG_EPD_DIS_BUF_LINES / 2)
// EDP 引脚
#define EPD_PIN_BUSY CONFIG_EPD_GPIO_BUSY
#define EPD_PIN_RESET CONFIG_EPD_GPIO_RST
#define EPD_PIN_DC CONFIG_EPD_GPIO_DC
#define EPD_PIN_CS CONFIG_EPD_GPIO_CS
#define EPD_PIN_SCK CONFIG_EPD_GPIO_SCK
#define EPD_PIN_SDA CONFIG_EPD_GPIO_SDA

// EDP SPI 配置
#define EPD_SPI_HOST (spi_host_device_t)(CONFIG_EPD_SPI_HOST - 1)
#define EPD_SPI_CLOCK_HZ (CONFIG_EPD_SPI_FREQ_MHZ * 1000000)
#define EPD_SPI_QUEUE_SIZE 3
#define EPD_SPI_MAX_TRANSFER_SZ EPD_DIS_BUF_SIZE

extern epd_handle_t *g_epd;

esp_err_t app_epd_init(void);
void app_epd_run(void *arg);
esp_err_t app_epd_notify_image_updated(void);

#endif /* _APP_EPD_H_ */